package com.sx.service.system;

import com.sx.basic.ResponseEntity;
import com.sx.basic.service.BasicService;
import com.sx.basic.service.impl.BasicServiceImpl;
import com.sx.dao.system.RoleRepository;
import com.sx.entity.system.RoleEntity;
import com.sx.service.system.IRoleService;
import org.springframework.stereotype.Service;

/**
 * @author AdinZ
 * @date 2020/11/10 18:23
 */
@Service
public class RoleService extends BasicServiceImpl<RoleRepository, RoleEntity,Long>
        implements IRoleService, BasicService<RoleEntity, Long> {

    public RoleEntity get(Long id){
        RoleEntity entity= this.redisService.get(RoleEntity.KEY,id);
        if(entity==null){
            entity=super.get(id);
            if(entity!=null)this.redisService.set(RoleEntity.KEY,entity.getId(),entity);
        }
        return entity;
    }

    @Override
    public ResponseEntity rolePut(RoleEntity entity) {
        save(entity);
        return toSuccess();
    }




}
